package com.sskj.gocoin.mine;

import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;
import com.sskj.gocoin.MyAppLication;
import com.sskj.gocoin.common.Constants;
import com.sskj.gocoin.m.HttpConfig;
import com.sskj.gocoin.m.bean.HttpData;
import com.sskj.gocoin.m.bean.UserInfo;
import com.sskj.gocoin.m.http.JsonCallBack;
import com.sskj.gocoin.p.base.BasePresenter;
import com.sskj.gocoin.utils.SPUtils;


/**
 * @author Hey
 * Create at  2019/04/02
 */
class VerifyHomePresenter extends BasePresenter<VerifyHomeActivity> {
    public void request() {
        OkGo.<HttpData<UserInfo>>get(HttpConfig.BASE_URL + HttpConfig.GET_USER_INFO)
                .params("mobile", MyAppLication.getMobile())
                .execute(new JsonCallBack<HttpData<UserInfo>>(this) {
                    @Override
                    protected void _onSuccess(Response<HttpData<UserInfo>> response) {
                        HttpData<UserInfo> httpData = response.body();
                        if (httpData.getCode() == 200) {
                            SPUtils.putBean(mView, Constants.SP_USER_INFO, httpData.getData());
                            SPUtils.put(MyAppLication.getApplication(), Constants.SP_REALNAME_STATUS, httpData.getData().getAuthentication());
                            mView.updateStatus(httpData.getData());
                        }
                    }
                });
    }

}
